package com.study.proxy;
/*
* 好处 代理对象可以做真实对象做不了的事情
*
* */
public interface MarryProxy {
    /**
     * 结婚方法
     */
    void happyMarry();
}

class You implements MarryProxy{

    public void happyMarry() {
        System.out.println("你要结婚了");
    }
}


/**
 * 代理角色帮助你结婚
 */
class MasterOfCeremonies implements MarryProxy{
   private MarryProxy marry;

    public MasterOfCeremonies(MarryProxy marry) {
        this.marry = marry;
    }

    public void happyMarry() {
     before();
     // 调用被代理对象
     this.marry.happyMarry();
     after();
    }

    private void after() {
        System.out.println("结婚之后 收尾款");
    }

    private void before() {
        System.out.println("结婚之前布置现场");
    }
    public static void main(String[] args) {
        // 相当于 runnable 对象
        You you = new You();
       new MasterOfCeremonies(you).happyMarry();
    }
}
